# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Henrik Riomar <henrik.riomar@gmail.com>
pkgname=safekeep
pkgver=1.5.1
pkgrel=2
pkgdesc="SafeKeep backup system"
url="https://github.com/dimipaun/safekeep"
arch="noarch"
license="GPL-2.0-or-later"
depends="openssh-client python3 rdiff-backup util-linux-misc"
makedepends="asciidoc libxml2-utils xmlto"
install="$pkgname-server.post-install"
subpackages="$pkgname-doc $pkgname-client $pkgname-server"
source="$pkgname-$pkgver.tar.gz::https://github.com/dimipaun/$pkgname/archive/$pkgver.tar.gz
	"

build() {
	make man
	# ionice from util-linux is in /usr/bin (busybox in /bin)
	sed -i 's|PATH=/sbin:/bin:/usr/sbin:/usr/bin|PATH=/sbin:/usr/sbin:/usr/bin:/bin|' safekeep.cron
}

check() {
	PATH=".:$PATH" make check
}

client() {
	pkgdesc="SafeKeep backup system - client"
	depends="$pkgname=$pkgver-r$pkgrel"

	mkdir -p "$subpkgdir"
	# just a meta package
}

server() {
	pkgdesc="SafeKeep backup system - server"
	depends="$pkgname=$pkgver-r$pkgrel"

	mkdir -p "$subpkgdir"
	mv "$pkgdir"/etc "$subpkgdir"/etc
	mkdir "$subpkgdir"/etc/periodic
	mv "$subpkgdir"/etc/cron.daily "$subpkgdir"/etc/periodic/daily
}

package() {
	make install DESTDIR="$pkgdir"
}

sha512sums="8977edadc48ccff4cf6cc524addf0b47a10320fb134adc78ff6663b33d8856393a448212814224b990f4f77876b06b1ef2fb47fe6e4a8a8d3678b0900c6b54f3  safekeep-1.5.1.tar.gz"
